﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmCapNhatLoaiThietBi : DevComponents.DotNetBar.Metro.MetroForm
    {
        public delegate void CapNhat(LoaiThietBiDTO dto);
        public event CapNhat KhiCapNhat = null;
        
        public frmCapNhatLoaiThietBi()
        {
            InitializeComponent();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (txtTenLoaiThietBi.Text != "")
            {
                LoaiThietBiDTO dto = LayThongTin();
                if (KhiCapNhat != null)
                    KhiCapNhat(dto);
            }
            else
            {

                DevComponents.DotNetBar.MessageBoxEx.Show("Bạn chưa nhập tên loại thiết bị!", "eMobile - Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                txtTenLoaiThietBi.Focus();
            }
        }

        LoaiThietBiDTO LayThongTin()
        {
            LoaiThietBiDTO ltbdto = new LoaiThietBiDTO();
            ltbdto.MaLoaiThietBi = frmMain.maltb;
            ltbdto.TenLoaiThietBi = txtTenLoaiThietBi.Text;
            return ltbdto;
        }

        private void frmCapNhatLoaiThietBi_Load(object sender, EventArgs e)
        {
            LoaiThietBiBUS bus = new LoaiThietBiBUS();
            txtTenLoaiThietBi.Text = bus.LayTenLoaiThietBiTheoMa(frmMain.maltb);
        }
    }
}